﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;

namespace HYElectricSystemSetting
{
	public partial class CreateWireThoroughPipeType : System.Windows.Forms.Form
	{
		public CreateWireThoroughPipeType(ComboBox cmbConduitType)
		{
			this.InitializeComponent();
			this.cmbConduitType = cmbConduitType;
		}

		private void CreateWireThoroughPipeType_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			if (ElectricSystemSettingData.ConduitTypeDatas == null)
			{
				return;
			}
			this.cmbBaseOn.DisplayMember = "ConduitTypeSet";
			foreach (ConduitTypeSetClass item in ElectricSystemSettingData.ConduitTypeDatas)
			{
				this.cmbBaseOn.Items.Add(item);
			}
			if (this.cmbBaseOn.Items.Count > 0)
			{
				this.cmbBaseOn.SelectedIndex = 0;
			}
		}

		private void btnok_Click(object sender, EventArgs e)
		{
			ConduitTypeSetClass conduitTypeSetClass = (ConduitTypeSetClass)this.cmbBaseOn.SelectedItem;
			for (int i = 0; i < this.cmbConduitType.Items.Count; i++)
			{
				if (((ConduitTypeSetClass)this.cmbConduitType.Items[i]).Id == conduitTypeSetClass.Id)
				{
					MessageBox.Show("已有相同线管类型", "盈建科提示！");
					this.ischecked = false;
					return;
				}
			}
			this.ischecked = true;
		}

		private void btncancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void CreateWireThoroughPipeType_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (base.DialogResult == DialogResult.OK && !this.ischecked)
			{
				e.Cancel = true;
			}
		}

		private ComboBox cmbConduitType;

		private bool ischecked;
	}
}
